const env = 'production';

const hosts = {
	development: '',
	production: 'https://shetest.tuoketech.com'
}

const api = {
	user: {
    login: {
      method: 'POST',
      url: '/api/member/login'
    },
    bookshelf: {
      method: 'GET',
      url: '/api/member/bookshelf'
    },
    payment: {
    	method: 'POST',
    	url: '/api/payment/place'
    },
    userInfo: {
    	method: 'POST',
    	url: '/api/member/profile'
    }
  },
	category: {
		courseCategory: {
			method: 'GET',
			url: '/api/category/'
		},
		pageList: {
			method: 'GET',
			url: '/api/category/page'
		},
		list: {
			method: 'GET',
			url: '/api/category/list'
		}
	},
	course: {
		courseInfo: {
			method: 'GET',
			url: '/api/course/'
		},
		pageList: {
			method: 'GET',
			url: '/api/course/page'
		},
		listSupreme: {
			method: 'GET',
			url: '/api/course/listSupreme'
		},
		lessonPlayProgress: {
			method: 'post',
			url: '/api/records/lesson/progress'
		},
		lessonPlayCount: {
			method: 'post',
			url: '/api/records/lesson/count'
		},
	},
	ad: {
		pageList: {
			method: 'GET',
			url: '/api/ad/page'
		},
		list: {
			method: 'GET',
			url: '/api/ad/list'
		}
	},
	invite:{
		invite: {
			method: 'POST',
			url: '/api/lake/createLakeUser'
		},
		accountInfo: {
			method: 'POST',
			url: '/api/member/account'
		},
		record: {
			method: 'POST',
			url: '/api/member/amount/record'
		},
	}
}

module.exports = {
  env,
  api: disposeUrl(api, hosts[env])
}

function disposeUrl(obj, prefix) {
  Object.keys(obj).forEach(v => {
    if (obj[v].url) {
      obj[v].url = prefix + obj[v].url
    } else {
      obj[v] = disposeUrl(obj[v], prefix)
    }
  })
  return obj
}